// pages/message/index/index.js
const app = getApp()

Page({
  data: {
    friend_list: []
  },

  onShow(options) {
    this.get_friend()
  },

  get_friend: function () {
    let _this = this
    let data = {
      'identity_user': app.globalData.chat_info['sender_identity'],
      'userid': app.globalData.chat_info['sender_id']
    }
    app.formPost('/get_fridend?', data).then(res => {
      console.log('获取好友列表:', res);
      _this.setData({
        friend_list: res
      })
      console.log(_this.data.friend_list[0]);
    })
  },

  gotoChat: function (e) {
    // console.log(e['currentTarget']['dataset']);
    app.globalData.chat_info['receiver_id'] = e['currentTarget']['dataset']['receiver_id']
    if (e['currentTarget']['dataset']['receiver_identity'] == '教师') {
      app.globalData.chat_info['receiver_identity'] = 1
    }else {
      app.globalData.chat_info['receiver_identity'] = 0
    }
    wx.navigateTo({
      url: '/pages/message/chat/chat',
    })
  },

  gotoAddressBook: function() {
    wx.navigateTo({
      url: '/pages/message/addressBook/addressBook',
    })
  },

  onReady() {

  },

  onHide() {

  },

  onUnload() {

  },

  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})